package com.doit.day02;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Tuple;

import java.util.Set;

public class ResDemo {
    public static void main(String[] args) throws InterruptedException {
        //首先获取到redis对象
        Jedis redis = new Jedis("linux01", 6379);
        //将hero 这个key  按照次数的降序进行排列，返回前三名 ZREVRANGEBYSCORE
        while (true){
            Set<Tuple> hero = redis.zrevrangeWithScores("hero", 0, 2);
            for (Tuple tuple : hero) {
                String elem = tuple.getElement();
                Double score = tuple.getScore();
                System.out.println("英雄是："+elem +",次数是："+score);
            }
            System.out.println("=================="+System.currentTimeMillis()+"=========================");
            Thread.sleep(3000);




        }
    }
}
